package bavaria.hightech.testit.guis;


import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.TimerTask;
import java.util.Timer;
import java.util.Calendar;
import java.util.Date;
import java.text.DateFormat;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Zeichenstube extends JFrame {
    private static final int TICK_PERIOD = 1000;
    private Timer ticker;
    private JPanel panel;

    private class TickerTask extends TimerTask {
        public void run() {
            panel.repaint();
        }
    }

    private static class ClockDisplay extends JPanel {
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Calendar cal = Calendar.getInstance();
            Date date = cal.getTime();
            DateFormat dateFormatter = DateFormat.getTimeInstance();
            g.setFont(new Font(null,Font.PLAIN,20));
            g.drawString(dateFormatter.format(date), 20, 50);
            dateFormatter = DateFormat.getDateInstance();
            g.drawString(dateFormatter.format(date), 10, 30);
            g.drawOval(40, 40, 200, 200);
            g.drawLine(40, 140, 240, 140);
            g.drawLine(140,40,140,240);
            g.drawString("12",130,60);
            g.drawString("1", 190, 75);
            Image img = Toolkit.getDefaultToolkit().getImage("Uhren_Zifferblatt_4.jpg");
            g.drawImage(img, 40, 40, this);
            
        }
    }


    public Zeichenstube() {
        panel = new ClockDisplay();
        add("Center", panel);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(300, 300);
        setVisible(true);

    }

    public void start() {
        ticker = new Timer(true); //as daemon
        ticker.scheduleAtFixedRate(new TickerTask(), 0, TICK_PERIOD);
    }

    public static void main(String[] args) {
        Zeichenstube clock = new Zeichenstube();
//       clock.start();
    }
}
